/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

/**
 *
 * @author Thijs
 */
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UserStringValidator
{

    private Pattern pattern;
    private Matcher matcher;
    private static final String USERNAME_PATTERN = "^[a-z0-9_-]{3,6}$";
    /*
     * [a-z0-9_-]	# Match characters and symbols in the list, a-z, 0-9,
     * underscore, hyphen {3,6} # Length at least 3 characters and maximum
     * length of 16
     */

    public UserStringValidator()
    {
        pattern = Pattern.compile(USERNAME_PATTERN);
    }

    public boolean validate(final String productname)
    {

        matcher = pattern.matcher(productname);
        return matcher.matches();

    }
}
